package org.jeecg.modules.xindian.reconciliation.enums;

import lombok.Data;

import java.util.Arrays;
import java.util.Optional;

public enum InsuranceCompanyEnum {

    安吉阳光投标保函("TBaoHanAJYGGR", "YGBX"),
    湖州阳光投标保函("TBaoHanHZYGGR", "YGBX"),
    浙江阳光投标保函("TBaoHanZJYGBXGR", "YGBX"),
    大家财险("TBaoHanZJDJCXHR", "DJCX"),
    华安保险("TBaoHanZJHAGR", "HABX"),
    阳光保险1("ZJYGBXGR", "YGBX"),
    大家财险2("ZJDJCXHR", "DJCX"),
    协荣_大家财险("ZJDJBXXR", "DJCX"),
    华安保险3("ZJHAGR", "HABX");



    private String insuranceCompanyCode;
    private String productCode;

    public String getInsuranceCompanyCode() {
        return insuranceCompanyCode;
    }

    public String getProductCode() {
        return productCode;
    }

    InsuranceCompanyEnum(String insuranceCompanyCode, String productCode) {
        this.insuranceCompanyCode = insuranceCompanyCode;
        this.productCode = productCode;
    }

    public static String findByProductCode(String productCode) {
        Optional<InsuranceCompanyEnum> companyEnum = Arrays.stream(InsuranceCompanyEnum.values()).filter(insuranceCompanyEnum -> {
            return insuranceCompanyEnum.getInsuranceCompanyCode().equals(productCode);
        }).findFirst();
        return companyEnum.map(insuranceCompanyEnum -> insuranceCompanyEnum.productCode).orElse(null);
    }
}
